#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
#define Max 1005
int vis[Max];
int Arr[Max][Max];
int Many[Max];
int Fa[Max];
int n, m;
int find(int x) {
	if (Fa[x] == x) return x;

	return Fa[x] = find(Fa[x]);
}
void merge(int j, int i) {
	int fx = find(j);
	int fy = find(i);
	if (fx != fy)
	{
		Fa[fx] = fy;
		Many[fy] += Many[fx];
		if (Many[fy] > (n + 1) / 2)
		{
			cout << i << endl;
		}
		}
}
void ini(int n)
{
	for (int i = 1; i <= n; i++)
	{
		vis[i] = 0;
		Many[i] = 1;
		Fa[i] = i;
	}

}
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> Arr[i][0];
		for (int j = 1; j <= Arr[i][0]; j++) {
			cin >> Arr[i][j];
		}
	}
	ini(n);
	for (int i = n; i >= 1; i--) {

		for (int k = 1; k <= Arr[i][0]; k++)
		{
			if (Arr[i][k] > i)
			{
				int fx = find(Arr[i][k]);
				int fy = find(i);
				if (fx != fy)
				{
					Fa[fx] = fy;
					Many[fy] += Many[fx];
					if (Many[fy] > (n + 1) / 2)
					{
						cout << i << endl;
						return 0;
					}
				}
			}
		}
	}
	
	return 0;
}
/*
#include<bits/stdc++.h>
using namespace std;
#define Max 1005
int vis[Max];
int Arr[Max][Max];
int Many[Max];
int Fa[Max];
int n, m;
void init(int n)
{
	for (int i = 1; i <= n; i++)
	{
		vis[i] = 0;
		Many[i] = 1;
		Fa[i] = i;
	}
}
int find(int k)
{
	
	if (Fa[k] == k)
		return k;
	else
	{
		Fa[k] == find(Fa[k]);
		return Fa[k];
	}
		
}
void merge(int i, int j)
{
	int x = find(i);
	int y = find(j);
	if (x == y || !vis[i] || !vis[j])
	{
		return;
	}
	if (x <y)
	{
		Fa[y] = x;
		Many[x]+=Many[y];
	}
	else
	{
		Fa[x] =y;
		Many[y] += Many[x];
	}
}
int main()
{

	cin >> n;
	for (int i = 1; i <=n; i++)
	{
		cin >> m;
		Arr[i][0] = m;
		for (int j = 1; j <= Arr[i][0]; j++)
		{
			cin >> Arr[i][j];
		}
	}

	for (int i = 1; i <= n; i++)
	{
		vis[i] = 0;
		Many[i] = 1;
		Fa[i] = i;
	}

	for (int i = n; i >= 1; i--)
	{
		vis[i] = 1;
		for (int j = 1; j <= Arr[i][0]; j++)
		{
			merge(i, Arr[i][j]);
		}for (int a = 1; a <= n; a++)
	  {
		  if (Many[a] > n / 2)
		  {
			  cout << i << endl;
			  return 0;
		  }
	  }
		
	}
}*/